<?php
require_once __DIR__ . '/db_config.php';


$host = DB_SERVER; // host of MySQL server
$user = DB_USER; // MySQL user
$pwd = DB_PASSWORD; // MySQL user's password
$db = DB_DATABASE; // database name
 
// Create connection
$con = mysqli_connect($host, $user, $pwd, $db);
 
// Check connection
if(mysqli_connect_errno($con)) {
    die("Failed to connect to MySQL: " . mysqli_connect_error());
}
// an array to save the application data
	$rows = array();
 if (isset($_GET["username"]) && isset($_GET["password"])) {//Du lieu truyen vao de kiem tra
    $user = $_GET['username'];
	$pass = $_GET['password'];
	// query the application data
	$sql = "SELECT * FROM taikhoan WHERE USERNAME='$user' AND PASS='$pass'";
	$result = mysqli_query($con, $sql);
	 
	
	
	// iterate to query result and add every rows into array
	while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
		$rows[] = $row;
	}
}
// close the database connection
mysqli_close($con);
 
// echo the application data in json format
echo json_encode($rows);
